/**
 * @type {String}
 *
 * @properties={typeid:35,uuid:"0F265D8A-8A57-436D-A516-4DAC7A1916D2"}
 */
var fError = null;

/**
 * @type {String}
 *
 * @properties={typeid:35,uuid:"92511700-3AAE-46D4-A529-324A61ADE215"}
 */
var fUser = null;

/**
 * @type {String}
 *
 * @properties={typeid:35,uuid:"DEA3AC51-6D45-48F3-8FA9-4524BE92490F"}
 */
var fPass = null;

/**
 *
 * @properties={typeid:24,uuid:"7F4C7759-A5B2-46AF-BAA0-DDBB604EA992"}
 * @AllowToRunInFind
 */
function Entrar()
{
	var ok = security.authenticate("mod_login_userv_auth","autenticar",[fUser,fPass]) 
	if (ok == 1)
	{
		return true
	}
	else
	{
		switch (ok)
		{
			case 2:
			{
				//globals.DIALOGS.showErrorDialog('Error','Permiso denegado','OK')
				fError = '*Permiso denegado'
				break;
			}
			case 3:
			{
				//globals.DIALOGS.showErrorDialog('Error','Contraseña incorrecta','OK')
				fError = '*Contraseña incorrecta'
				break;
			}
			case 4:
			{
				//globals.DIALOGS.showErrorDialog('Error','Usuario no existe','OK')
				fError = '*Usuario no existe'
				break;
			}
		}
		return false
	}
}

/**
 * Callback method for when form is shown.
 *
 * @param {Boolean} firstShow form is shown first time after load
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"ECEADF9B-9E55-4392-B9C6-7776DB16735A"}
 */
function onShow(firstShow, event) {
	elements.lbl_solucion.text = application.getSolutionName().toUpperCase()
	elements.fld_user.requestFocus()
}

/**
 * Handle hide window.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @returns {Boolean}
 *
 * @properties={typeid:24,uuid:"6714153A-BBE6-4AFA-8374-3B2A62C5EA15"}
 */
function onHide(event) {
	if (security.getUserName() == null)
		return false
		
	return true
}

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"BE3FD072-4083-4D2D-9AC3-9AF600F40091"}
 */
function salir(event) {
	application.exit()
}

/**
 * Handle focus gained event of the element.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"B96C37EE-BE65-4F41-BF3E-1D4683443622"}
 */
function borrarMensaje(event) {
	fError = null
}
